<?php

/**
 * This is the model class for table "{{teacher}}".
 *
 * The followings are the available columns in table '{{teacher}}':
 * @property double $teacher_id
 * @property string $teacher_name
 * @property string $teacher_num
 * @property string $teacher_pswd
 * @property double $subject_id
 * @property string $subject_name
 * @property double $school_id
 * @property string $school_name
 * @property double $exam_id
 * @property double $leader
 * @property double $addtime
 */
class Teacher extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Teacher the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{teacher}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('subject_id, school_id, exam_id, leader, addtime', 'numerical'),
			array('teacher_name, teacher_num, teacher_pswd, subject_name, school_name', 'length', 'max'=>50),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('teacher_id, teacher_name, teacher_num, teacher_pswd, subject_id, subject_name, school_id, school_name, exam_id, leader, addtime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'teacher_id' => 'Teacher',
			'teacher_name' => 'Teacher Name',
			'teacher_num' => 'Teacher Num',
			'teacher_pswd' => 'Teacher Pswd',
			'subject_id' => 'Subject',
			'subject_name' => 'Subject Name',
			'school_id' => 'School',
			'school_name' => 'School Name',
			'exam_id' => 'Exam',
			'leader' => 'Leader',
			'addtime' => 'Addtime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('teacher_id',$this->teacher_id);
		$criteria->compare('teacher_name',$this->teacher_name,true);
		$criteria->compare('teacher_num',$this->teacher_num,true);
		$criteria->compare('teacher_pswd',$this->teacher_pswd,true);
		$criteria->compare('subject_id',$this->subject_id);
		$criteria->compare('subject_name',$this->subject_name,true);
		$criteria->compare('school_id',$this->school_id);
		$criteria->compare('school_name',$this->school_name,true);
		$criteria->compare('exam_id',$this->exam_id);
		$criteria->compare('leader',$this->leader);
		$criteria->compare('addtime',$this->addtime);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}